# coding: utf-8
class Profile
    def initialize(basic_hash, user)
        @driver = basic_hash['driver']
        @base_url = basic_hash['base_url']

        @user = user
    end

    #更新个人信息
    def update_profile
        show_menu

        # @driver.find_element(:xpath, "//a[contains(@href, '/profile')]").click
        @driver.find_element(:id, "user_open_email").clear
        @driver.find_element(:id, "user_open_email").send_keys @user['email']
        @driver.find_element(:id, "user_weibo").clear
        @driver.find_element(:id, "user_weibo").send_keys @user['weibo']
        @driver.find_element(:id, "user_qq").clear
        @driver.find_element(:id, "user_qq").send_keys @user['qq']
        @driver.find_element(:id, "user_home_page").clear
        @driver.find_element(:id, "user_home_page").send_keys @user['home_page']
        @driver.find_element(:id, "user_organization").clear
        @driver.find_element(:id, "user_organization").send_keys @user['organization']
        @driver.find_element(:id, "textarea").clear
        @driver.find_element(:id, "textarea").send_keys @user['textarea']
        @driver.find_element(:name, "commit").click

        @driver.find_element(:id, "drop1").click
    end

    #显示用户菜单
    def show_menu
        @driver.navigate.to @base_url+'/profile'
    end
end
